package com.gz.steak.common.web.result;

/**
 * @Author 刘牌
 * @Date 2020/2/22 0022 12:56
 * @Version 1.0
 */

public class Result {
    private int code;
    private Object data;

    public enum Type
    {
        /** 成功 */
        SUCCESS(1),
        /** 失败 */
        FAIL(0);
        private final int value;
        Type(int value)
        {
            this.value = value;
        }
        public int value()
        {
            return this.value;
        }
    }

    public static Result success(Object o){
        Result result = new Result();
        result.setCode(Type.SUCCESS.value);
        result.setData(o);
        return result;
    }

    public static Result fail(Object o){
        Result result = new Result();
        result.setCode(Type.FAIL.value);
        result.setData(o);
        return result;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
